﻿using System.ComponentModel.Composition;

namespace OperationPlugins.Validators.DataAnnotations
{
    [Export(typeof(IUsePluginValidatorsAttributeValidate))]
    [DefaultPriority]
    internal sealed class DefaultIUsePluginValidatorsAttributeValidate : IUsePluginValidatorsAttributeValidate
    {
        /// <summary>
        /// Validates an object.
        /// </summary>
        /// <param name="value">The object to be validated.</param>
        /// <param name="operation">Identifies the current operation.</param>
        /// <param name="branch">Identifies the current branch.</param>
        /// <param name="contextFactory">The IOperationContextFactory to be used.</param>
        /// <returns>The ValidationResultMessageContainer object.</returns>
        MessageContainer IUsePluginValidatorsAttributeValidate.Validate(object value, OperationId operation, BranchId branch, IOperationContextFactory contextFactory)
        {
            return Validator.Invoke(value, operation, branch, contextFactory);
        }
    }
}
